package o;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;

public class cpb {
    private static int ˏ = -1;

    public static int ˋ(Context context) {
        if (-1 == ˏ) {
            if (VERSION.SDK_INT < 26) {
                if (ˏ(context)) {
                    ˏ = 2;
                } else {
                    ˏ = 1;
                }
            } else if (ॱ(context)) {
                ˏ = 2;
            } else {
                ˏ = 1;
            }
        }
        return ˏ;
    }

    private static boolean ॱ(Context context) {
        PackageManager packageManager = context.getPackageManager();
        try {
            if ("com.android.packageinstaller".equals(packageManager.getPermissionInfo("com.android.packageinstaller.permission.REQUEST_DELETE_PACKAGES", 0).packageName) && packageManager.checkPermission("com.android.packageinstaller.permission.REQUEST_DELETE_PACKAGES", context.getPackageName()) == 0) {
                return true;
            }
            return false;
        } catch (NameNotFoundException e) {
            cnu.ˏ.ˊ("UninstallCapabilityDetector", "can not find DELETE_PACKAGES_PERMISSION");
            return false;
        }
    }

    public static boolean ˎ(Context context) {
        return (ˋ(context) & 2) != 0;
    }

    private static boolean ˏ(Context context) {
        return cpe.ˋ(context, "android.permission.DELETE_PACKAGES");
    }
}
